package org.intellij.plugins.junit4.action;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataKeys;
import com.intellij.openapi.project.Project;
import org.intellij.plugins.junit4.JUnitProjectComponent;
import org.intellij.plugins.junit4.JavaMethod;
import org.intellij.plugins.junit4.SelectedFile;
import org.intellij.plugins.junit4.JavaFile;

/**
 * Wrapper around AnActionEvent.
 * 
 * @author tomichj
 */
public class ActionEvent
{
    private AnActionEvent event;


    public ActionEvent(AnActionEvent event)
    {
        this.event = event;
    }

    public JavaFile getSelectedJavaFile()
    {
        return getSelectedFile().selectedFile();
    }

    public SelectedFile getSelectedFile() // never returns null
    {
        return new SelectedFile(event);
    }

    public JavaMethod getSelectedMethod()
    {
        SelectedFile file = getSelectedFile();
        if (file == null) return null;
        return file.currentMethod();
    }

//    private JUnitProjectComponent getComponent()
//    {
//        return JUnitProjectComponent.getProjectComponent(getProject());
//    }

//    private Project getProject()
//    {
//        Project p = DataKeys.PROJECT.getData(event.getDataContext());
//        assert p != null;
//        return p;
//    }
}
